package xml;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

public class ReadXMLFile {

	public Map<String, String> parse(InputStream inputStream, String[] keysWeAreInterestedIn) {

		try {

			SAXParserFactory factory = SAXParserFactory.newInstance();
			SAXParser saxParser = factory.newSAXParser();

			GenericHandler handler = new GenericHandler(keysWeAreInterestedIn);

			saxParser.parse(inputStream, handler);

			return handler.getValues();

		} catch (Exception e) {

			e.printStackTrace();

		}

		return new HashMap<String, String>();
	}

	public static void main(String[] args) {


	}

}
